package 设计模式.原型模式;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * @description:
 * @author: asd
 * @time: 2022/11/23 20:01
 */
//此为浅拷贝
public class thing2  implements Cloneable{
    private String name;
    private String dis;
    private ArrayList<Double> scorses = new ArrayList<>();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDis() {
        return dis;
    }

    public void setDis(String dis) {
        this.dis = dis;
    }

    public thing2() {
        System.out.println("构造器被执行");
    }
    public Object clone() throws CloneNotSupportedException {
        System.out.println("克隆成功");
        return (thing2)super.clone();
    }
    public void setValue(double scorse) {
        this.scorses.add(scorse);
    }

    public ArrayList getValue() {
        return this.scorses;
    }
}
class test1{
    public static void main(String[] args) throws CloneNotSupportedException {
        thing2 t1 = new thing2();
        t1.setValue(120);
        thing2 cloneThing = (thing2) t1.clone();
        cloneThing.setValue(130);
        System.out.println(t1.getValue());
    }
    /*
     * @description: 浅拷贝会将int，double,string,long型数据拷贝，对象内部的数组，引用对象都不拷贝，还是指向原生对象的内部元素地址
     * */
}